package com.pjedu.springbootrestful04.mapper;

import com.pjedu.springbootrestful04.entity.User;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface UserMapper extends Mapper<User> {
    //使用注解的形式来写查询语句
    @Select("<script>" +
            "select * from users"+
            "<where>" +
            "<if test=\"uid!=null\">" +
            "    and uid=#{uid}" +
            "</if>" +
            "<if test=\"username!=null\">" +
            "    and username=#{username}" +
            "</if>" +
            "<if test=\"password!=null\">" +
            "    and password=#{password}" +
            "</if>" +
            "</where>" +
            "</script>")
    public List<User> findAllByConditions(User user);
}
